home *** CD-ROM | disk | FTP | other *** search
-
- (******************************************************************************
- RDDBASE - Version 1.00 - 01/29/86
-
- Copyright(c) 1986,Third Wave Systems , ALL RIGHTS RESERVED
-
- Written by K.R. Grenier for Public Domain use ONLY.
-
- A colletion of Turbo Pascal Routines to be
- Used in reading and Updating DBASe III Files Outside of
- The DBASE III programing Environment,
-
-
- NOTICE!!!!
-
- RDDBASE may not be sold, used in a commerical environment, nor packaged with
- any commerical product without prior written permission from Third Wave
- Systems. The routines may be freely distributed and / or included in compiled
- Turbo Pascal Programs for commercial purposes.
-
- RDDBASE may be distributed freely at no cost to the recipient. User support
- for this utility may be best obtained by notifying Third Wave Systems.
-
- If you feel that this utility is of value, please feel free to send your
- voluntary contribution of $10.00. This contribution will entitle you to
- notification of Future updates and user support.
-
- Make your Contribution check payable to
-
- Third Wave Systems
- 131 E 22nd Ave A
- Box 124
- Coal Valley, Il 61240
-
-
- DESCRIPTION:
-
- RDDBASE is a collection of TURBO Pascal 3.0 procedures that allow the
- developer to write programs that read and update DBASE III database files
- outside the DBASE III environment.
-
- The procedures included are:
-
- Open_Dbase_File - Used to open a DBASE III file and set up necessary
- parameters.
-
- Close_Dbase_File - Used to close a DBASE III file and reset necessary
- header information
-
- Read_Dbase_Record - Reads DBASE III Record either sequentially
- or randomly
-
- Read_Previous_Dbase_Record - Reads the DBASE III backwards from the
- current record position
-
- Rewrite_Dbase_Record - Writes an uodated DBASE III record back to the
- database.
-
- TIPS.
-
- Multiple DataBases can be processed within one program. Be sure to
- assign each a variable name and a type of FILE.
-
- Limited global variables are used. Those required by RDDBASE begin
- with the prefix Db_ .
-
- At this time RDDBASE does not support the DBASE III indexing files.
- The developer can create TURBO Pascl indices using The TURBO TOOLBOX
- routines. These routines will build temporary indices rather quickly.
- When using these routines
- Create an index only
- Establish the Relative record counter manually
- The first record in the DBASE III file is Relative Record 1.
-
- To Delete DBASE III records set Byte one of the DBASE III record to
- *. Reorganize the database under the DBASE III environment using
- the appropriate indices.
-
- End of File is not Handled properly in all cases and may cause the
- program to terminate with an I/O if care is not taken.
-
- FUTURE ENHANCEMENTS
-
- Fix to EOF Problem.
-
- Process DBASE III indices.
-
- Ability to ADD records to the DBASE III files.
-
- Any suggestions or questions can be left on the
-
- COLLIER INTERNATIONAL BLUE BOARD
- 818-240-6006
-
- DISCLAIMER
-
- The author has taken due care in developing and testing the effectiveness of
- these routines, and makes no expressed or implied warranty of any kind.
- In no event shall the author or Third Wave Systems be liable for incidental
- or consequential damages in connection with or arising out of the use of
- these routines.
-
- NOTES
- -----
-
- DBASE III is a trademark of ASHTON-TATE.
- TURBO PASCAL is a trademark of BORLAND INTERNATIONAL.
- TURBO PASCAL TOOLBOX is a trademark of BORLAND INTERNATIONAL.
-
- ************************************************************************)
-
-
- (*************** Required Variables and Constants ****************)
- Type
- Db_File_Information_Block = Record
- Header_Size,
- Record_Size :Integer;
- end;
-
- Db_String80 =String[80];
-
- Var
- Db_File_Information :Array[1..30] of Db_File_Information_Block;
- Db_Handle :integer;
- Db_Offset :Real;
-
- (*********************** Open A Dbase File ******************************)
-
- Procedure Open_Dbase_File(Var Dbase_File :File;
- FileName :Db_String80);
-
-
- Begin
- Assign(DBase_File,FileName);
- Reset(Dbase_File,1);
- Move(Dbase_File,Db_Handle,2);
- Longseek(Dbase_File,8);
- BlockRead(Dbase_File,Db_File_Information[Db_Handle],4);
- Db_Offset:= 1.0 * Db_File_Information[Db_Handle].Header_Size;
- LongSeek(Dbase_File,Db_Offset);
- end; {of Open Dbase File }
-
- (********************** Close A Dbase File ***************************)
-
- Procedure Close_Dbase_File(Var Dbase_File :File);
-
- Begin
- Move(Dbase_File,Db_Handle,2);
- Longseek(Dbase_File,8);
- BlockWrite(Dbase_File,Db_File_Information[Db_Handle],4);
- Db_File_Information[Db_Handle].Header_Size:=0;
- Db_File_Information[Db_Handle].Record_Size:=0;
- Close(Dbase_File);
- end; {of Close Dbase File}
-
- (******************** Read Dbase Record ***************************)
-
- Procedure Read_Dbase_Record(Var Dbase_File :File;
- Relative_Key :Real;
- Var Dbase_Buffer);
-
- { Relative Key = 0 will Read Next Record
- Relative Key > 0 will Read Record At Given Relative_Key Position }
-
-
- Begin
- Move(Dbase_File,Db_Handle,2);
- With Db_File_Information[Db_Handle] do
- Begin
- If Relative_Key <> 0 then
- Begin
- Db_Offset:= (Abs(Relative_Key) - 1) * Record_Size + Header_Size;
- Longseek(Dbase_File,Db_OffSet);
- end; {Of If}
- BlockRead(Dbase_File,Dbase_Buffer,Record_Size);
- end; {Of With}
- end; {of Read Dbase Record}
-
- (******************** Read Previous Dbase Record ***************************)
-
- Procedure Read_Previous_Dbase_Record(Var Dbase_File :File;
- Relative_Key :Real;
- Var Dbase_Buffer);
-
- { Relative Key = 0 will ReRead Current Record Read
- Relative Key > 0 will Backup and Read The record at - relative key position}
-
-
-
- Begin
- Move(Dbase_File,Db_Handle,2);
- With Db_File_Information[Db_Handle] do
- Begin
- Db_Offset:=LongFilePos(Dbase_File);
- Db_Offset:=Db_Offset - (Abs(Relative_Key) + 1.0) * Record_Size;
- If Db_Offset < 1.0 * Header_Size then
- Db_Offset := 1.0 * Header_Size;
- Longseek(Dbase_File,Db_OffSet);
- BlockRead(Dbase_File,Dbase_Buffer,Record_Size);
- end; {Of With}
- end; {of Read Previous Dbase Record}
-
- (******************** ReWrite Dbase Record ***************************)
-
- Procedure Rewrite_Dbase_Record(Var Dbase_File :File;
- Relative_Key :Real;
- Var Dbase_Buffer);
-
- { Relative Key not Used }
-
- Begin
- Move(Dbase_File,Db_Handle,2);
- With Db_File_Information[Db_Handle] do
- Begin
- Db_Offset:=LongFilePos(Dbase_File);
- Db_Offset:=Db_Offset - 1.0 * Record_Size;
- If Db_Offset < 1.0 * Header_Size then
- Db_Offset := 1.0 * Header_Size;
- Longseek(Dbase_File,Db_OffSet);
- BlockWrite(Dbase_File,Dbase_Buffer,Record_Size);
- end; {Of With}
- end; {of Rewrite Dbase Record}
-
- (********************* End of Routines *************************************)